package lab03.test9;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Client {
    public static void main(String[] args) {
        List<Book> book=new ArrayList<Book>();
        String path="D:\\book.txt";
        String path1="D:\\book1.txt";
        BufferedReader bufferedReader=null;
        BufferedWriter bufferedWriter=null;
        try {
            bufferedReader=new BufferedReader(new FileReader(path));
            bufferedWriter=new BufferedWriter(new FileWriter(path1));
            String line=null;
            while ((line=bufferedReader.readLine())!=null){
             String[] token=line.split("\t");
             Book book1=new Book();
             book1.bookNumble=Integer.parseInt(token[0]);
             book1.bookName=token[1];
             book1.vionsion=token[2];
             book1.price=Double.parseDouble(token[3]);
             book1.seles=Double.parseDouble(token[4]);
             book.add(book1);
            }
            int i=1;
            for (Book b:book){
                if (i==3){
                    b.price=b.price+20;
                }
                if (i==4){
                    b.price=b.price+30;
                }
                bufferedWriter.write(b.bookNumble+b.bookName+b.vionsion+b.price+b.seles);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try {
                bufferedWriter.close();
                bufferedReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
